/**
 * 
 */
package co.fitstart.entity.order;

import java.beans.Transient;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.MapKey;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.annotations.DynamicUpdate;

import com.demo2do.core.format.DecimalFormat;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

import co.fitstart.entity.coupon.Coupon;
import co.fitstart.entity.course.Course;
import co.fitstart.entity.principal.Principal;
import co.fitstart.entity.product.Product;
import co.fitstart.entity.site.Site;
import co.fitstart.entity.user.Student;
import co.fitstart.entity.user.User;
import co.fitstart.entity.user.UserSourceType;
import co.fitstart.entity.user.agent.Agent;
import co.fitstart.entity.user.agent.AgentDiscount;
import co.fitstart.entity.utils.DateFormatUtils;

/**
 * 
 * @author mohanlan
 *
 */
@Entity
@Table(name = "orders")
@DynamicUpdate
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class Order {

    @Id
    @GeneratedValue
    private Long id;
    
    /** 订单号 */
    private String code;

    /** 订单类型 */
    @Enumerated(EnumType.ORDINAL)
    private OrderType orderType;
    
    @ManyToOne(fetch = FetchType.EAGER, optional = true)
    private UserSourceType userSourceType;
    
    /** sku */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private Product product;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private Course course;

    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private Site site;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private User user;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private Student student;
    
    /** 原价 */
    @DecimalFormat
    private int originalPrice;
    
    /** 订单金额 金额*100 */
    @DecimalFormat
    private int price;
    
    /** 定金 */
    @DecimalFormat
    private int deposit;
    
    /** 已支付部分金额 */
    private int offer;
    
    /** 是否支付部分金额 */
    private boolean payOffer;
    
    /** 实付金额 */
    private int paidPrice;
    
    /** 退款支付方式 */
    private RefundMethod refundMethod;
    
    /** 退款金额 */
    @DecimalFormat
    private int refundPrice;
    
    /** 份数 */
    private int amount;
    
    /** 创建时间/下单时间 */
    private Date createTime;
    
    /** 支付时间 */
    private Date payTime;
    
    /** 支付流水号 */
    private String payCode;
    
    /** 备注 */
    private String remarks;
    
    /** 销售渠道 */
    private DistributionChannel distributionChannel;

    /** 支付方式 */
    @Enumerated(EnumType.ORDINAL)
    private PaymentMethod paymentMethod;
    
    /** 订单状态 */
    @Enumerated(EnumType.ORDINAL)
    private OrderStatus orderStatus;
    
    /** 支付状态 */
    @Enumerated(EnumType.ORDINAL)
    private PaymentStatus paymentStatus;
    
    /** 订单属性 */
    @OneToMany(mappedBy = "order", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @MapKey(name = "name")
    @JsonIgnore
    private Map<String, OrderAttribute> attrs;
    
    /** 是否已调查 */
    private boolean investiged;
    
    private boolean uploadWxc;
    
    private boolean uploadLjz;
    
    /** 是否删除 */
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /** 优惠券码 */
    private String discountCode;
    
    /** 回扣 */
    @DecimalFormat
    private int commission;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private Agent agent;
    
    /** 销售人员 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private Principal salesman;
    
    /** 是否已导出销售订单 */
    private boolean exportSale;
    
    /** 是否已导出收款单 */
    private boolean exportReceipt;
    
    private String courseTags;
    
    /**
     * default constructor
     */
    public Order() {
        
    }

    /**
     * @param amount
     */
    public Order(int amount) {
        this.amount = amount;
    }
    
    /**
     * 
     * @param orderNo
     * @param user
     * @param product
     * @param price
     */
    public Order(String orderNo, User user, Product product, int price) {
        this.amount = 1;
        this.code = orderNo;
        this.orderType = OrderType.ACTIVITY;
        this.user = user;
        this.product = product;
        this.course = product.getCourse();
        this.originalPrice = price;
        this.price = price;
        this.deposit = 0;
        this.offer = 0;
        this.payOffer = false;
        this.paidPrice = 0;
        this.createTime = new Date();
        this.orderStatus = OrderStatus.CREATED;
        this.paymentStatus = PaymentStatus.UNPAID;
        this.refundPrice = 0;
        this.commission = 0;
        this.investiged = false;
        this.uploadWxc = false;
        this.uploadLjz = false;
        this.disabled = false;
        this.exportSale = false;
        this.exportReceipt = false;
    }
    
    /**
     * initialize order with order no, user and product
     * 
     * @param orderNo
     * @param user
     * @param product
     * @return
     */
    public Order initialize(String orderNo, User user, Product product) {
        this.code = orderNo;
        this.user = user;
        this.product = product;
        this.course = product.getCourse();
        this.createTime = new Date();
        this.orderStatus = OrderStatus.CREATED;
        this.paymentStatus = PaymentStatus.UNPAID;
        this.refundPrice = 0;
        this.exportSale = false;
        this.exportReceipt = false;
        this.offer = 0;
        this.payOffer = false;
        return this;
    }
    
    /**
     * 
     * @param orderNo
     * @param user
     * @param product
     * @param site
     * @return
     */
    public Order initialize(String orderNo, User user, Product product, Site site) {
        this.site = site;
        this.code = orderNo;
        this.user = user;
        this.product = product;
        this.course = product.getCourse();
        this.createTime = new Date();
        this.orderStatus = OrderStatus.CREATED;
        this.paymentStatus = PaymentStatus.UNPAID;
        this.refundPrice = 0;
        this.exportSale = false;
        this.exportReceipt = false;
        this.offer = 0;
        this.payOffer = false;
        return this;
    }
    
   /**
    * 
    * @param orderNo
    * @param user
    * @param product
    * @return
    */
    public Order initializeOnline(String orderNo, User user, Product product) {
        this.code = orderNo;
        this.user = user;
        this.product = product;
        this.course = product.getCourse();
        this.createTime = new Date();
        this.exportSale = false;
        this.exportReceipt = false;
        this.offer = 0;
        this.payOffer = false;
        return this;
    }
    
    /**
     * 
     * @param orderNo
     * @param user
     * @param product
     * @return
     */
    public Order initializeExperience(String orderNo, User user, Product product) {
        this.code = orderNo;
        this.user = user;
        this.product = product;
        this.course = product.getCourse();
        this.createTime = new Date();
        this.orderStatus = OrderStatus.PROCESSING;
        this.paymentStatus = PaymentStatus.UNPAID;
        this.paymentMethod = PaymentMethod.OTHER;
        this.exportSale = false;
        this.exportReceipt = false;
        this.offer = 0;
        this.payOffer = false;
        return this;
    }
    
    /**
     * 
     * @param orderType
     * @return
     */
    public Order initType(OrderType orderType) {
        this.orderType = orderType;
        return this;
    }
    
    /**
     * 
     * @return
     */
    public Map<String, Object> orderDetailDescribe() {
        Map<String, Object> parameters = new HashMap<String, Object>();
        
        parameters.put("code", this.code);
        parameters.put("orderType", this.orderType.getDescription());
        parameters.put("productName", this.getProductName());
        parameters.put("productCover", this.getProductCover());
        parameters.put("site", this.site == null ? "" : this.site.getName());
        parameters.put("amount", this.amount);
        parameters.put("createTime", DateFormatUtils.format(this.createTime, "yyyy-MM-dd HH:mm:ss"));
        parameters.put("paid", this.paymentStatus.isPaid() ? true : false);
        parameters.put("payTime", this.payTime == null ? "" : DateFormatUtils.format(this.payTime, "yyyy-MM-dd HH:mm:ss"));
        parameters.put("price", this.price/100);
        
        return parameters;
    }

    /**
     * Do calculatePrice order price
     * 
     * @return
     */
    public Order calculatePrice() {
        this.price = this.product.getCurrentOffer() * this.amount;
        this.addAttribute("orderPrice", this.price);
        this.deposit = 0;
        this.paidPrice = 0;
        return this;
    }
    
    /**
     * 
     * @return
     */
    public Order calculateWxcPrice() {
        this.price = 0;
        this.addAttribute("orderPrice", 0);
        this.deposit = 0;
        this.paidPrice = 0;
        return this;
    }
    
    /**
     * 
     * @return
     */
    public Order calculateGivePrice() {
        this.price = 0;
        this.addAttribute("orderPrice", 0);
        this.deposit = 0;
        this.paidPrice = 0;
        return this;
    }
    
    /**
     * 
     * @param coupon
     * @return
     */
    public Order calculatePrice(Coupon coupon) {
        this.originalPrice = this.product.getCurrentOffer() * this.amount;
        if(coupon.getTemplate().getDiscountType().isPercent()) {
            this.price = 0;
        } else {
            this.price = (this.product.getCurrentOffer() * this.amount) - coupon.getAmount();
        }
        this.addAttribute("orderPrice", this.price);
        this.deposit = 0;
        this.paidPrice = 0;
        return this;
    }
    
    /**
     * 
     * @return
     */
    public Order calculateExperienceCouponPrice() {
        this.originalPrice = this.product.getCurrentOffer() * this.amount;
        this.price = 0;
        this.addAttribute("orderPrice", this.price);
        this.deposit = 0;
        this.paidPrice = 0;
        return this;
    }
    
    /**
     * 
     * @param agentDiscount
     * @return
     */
    public Order bindAgentDiscount(AgentDiscount agentDiscount) {
        
        this.discountCode = agentDiscount.getDiscountCode();
        this.agent = agentDiscount.getAgent();
        if (this.originalPrice == 0) {
            this.originalPrice = this.price;
        }
        if(this.originalPrice == this.price) {
            this.price = agentDiscount.calculatePrice(this.price) <= 0 ? 1 : agentDiscount.calculatePrice(this.price);
        } else {
            this.price = agentDiscount.calculatePrice(this.price, this.originalPrice) <= 0 ? 1 : agentDiscount.calculatePrice(this.price, this.originalPrice);
        }
        
        this.commission = agentDiscount.calculateCommission(this.originalPrice);
        
        return this;
    }
    
    /**
     * 
     * @param student
     * @return
     */
    public Order bindOfflineCode(Student student) {
        this.discountCode = student.getOfflineCode();
        return this;
    }
    
    /**
     * @param name
     * @param value
     * @return
     */
    public Order addAttribute(String name, Object value) {
        if(this.attrs == null) {
            this.attrs = new HashMap<String, OrderAttribute>();
        }
        this.attrs.put(name, new OrderAttribute(this, name, value.toString()));
        return this;
    }
    
    /**
     * 
     * @param name
     * @return
     */
    public boolean hasAttribute(String name) {
        if(this.attrs == null) {
            return false;
        } else if(this.attrs.get(name) != null && StringUtils.isNotEmpty(this.attrs.get(name).getValue()) ){
            return true;
        }else {
            return false;
        }
    }
    
    /**
     * 
     * @return
     */
    public Order investiged() {
        this.investiged = true;
        return this;
    }
    
    /**
     * Do cancel order
     * 
     * @return
     */
    public Order cancel() {
        this.orderStatus = OrderStatus.CANCELED;
        this.paymentStatus = PaymentStatus.CANCELED;
        return this;
    }
    
    /**
     * Do judgment order 
     * @return
     */
    public boolean availableCancel() {
        return this.paymentStatus.equals(PaymentStatus.UNPAID);
    }
    
    /**
     *  
     * @return
     */
    public boolean availableRefund() {
        return this.paymentStatus.equals(PaymentStatus.PAID) && !this.orderStatus.isComplete();
    }
    
    /**
     * 
     * @return
     */
    public boolean isRefund() {
    	
    	return this.orderStatus.equals(OrderStatus.REFUNDED);
    }
    
    /**
     * 
     * @return
     */
    public boolean availableChangeSalesman() {
        return !this.orderStatus.equals(OrderStatus.CANCELED) && !this.orderStatus.equals(OrderStatus.REFUNDED);
    }
    
    /**
     * @param userId
     * @return
     */
    public boolean matches(Long userId) {
        return userId != null && this.user != null ? this.user.getId().equals(userId) : false;
    }
    
    /**
     * @return
     */
    public boolean isUnpaid() {
        return this.paymentStatus != null && this.paymentStatus.isUnpaid();
    }
    
    /**
     * 
     * @param key
     * @return
     */
    public String attrValue(String key) {
        if(this.attrs != null) {
            return this.attrs.get(key).getValue();
        }
        return null;
    }
    
    /**
     * 
     * @param site
     * @return
     */
    public Order site(Site site) {
        this.site = site;
        return this;
    }
    
    /**
     * 
     * @param student
     * @return
     */
    public Order student(Student student) {
        this.student = student;
        return this;
    }
    
    /**
     * 
     * @param payCode
     * @param payTime
     * @param channel
     * @param paidPrice
     * @return
     */
    public Order paid(String payCode, Date payTime, String channel, int paidPrice) {
        this.payCode = payCode;
        this.payTime = payTime;

        this.orderStatus = this.getOrderType().isOthers() ? OrderStatus.SHIPPING : OrderStatus.PENDING;
        this.paymentMethod = PaymentMethod.codeOf(channel);
        this.paymentStatus = PaymentStatus.PAID;
        
        this.paidPrice = this.paidPrice + paidPrice;
        
        return this;
    }
    
    /**
     * Change order pay code
     * 
     * @param payCode
     * @return
     */
    public Order payCode(String payCode) {
        this.payCode = payCode;
        return this;
    }
    
    /**
     * Change order pay time
     * 
     * @param payTime
     * @return
     */
    public Order payTime(Date payTime) {
        this.payTime = payTime;
        return this;
    }
    
    /**
     * Change order payment status
     * 
     * @param paymentStatus
     * @return
     */
    public Order paymentStatus(PaymentStatus paymentStatus) {
        this.paymentStatus = paymentStatus;
        return this;
    }
    
    /**
     * Change order payment method
     * 
     * @param paymentMethod
     * @return
     */
    public Order paymentMethod(PaymentMethod paymentMethod) {
        this.paymentMethod = paymentMethod;
        return this;
    }
    
    /**
     * Change order status
     * 
     * @param orderStatus
     * @return
     */
    public Order orderStatus(OrderStatus orderStatus) {
        this.orderStatus = orderStatus;
        return this;
    }
    
    /**
     * @param agentDiscount
     * @return
     */
    @Transient
    public int discount(AgentDiscount agentDiscount) {
        if (agentDiscount.getDiscountType().isPayment()) {
            return agentDiscount.getDiscountOffer();
        } else {
            BigDecimal discount = new BigDecimal(this.originalPrice).multiply(new BigDecimal(100-agentDiscount.getUserDiscount())).divide(new BigDecimal("100"));
            return discount.intValue();
        }
    }
    
    /**
     * 
     * @param product
     * @return
     */
    public Order editProduct(Product product) {
        this.product = product;
        return this;
    }
    
    /**
     * 
     * @param course
     * @return
     */
    public Order editCourse(Course course) {
        this.course = course;
        return this;
    }
    
    /**
     * 
     * @param refundPrice
     * @return
     */
    public Order editRefundPrice(BigDecimal refundPrice) {
        this.refundPrice = refundPrice.multiply(new BigDecimal(100)).intValue() - this.getPayingPrice();
        return this;
    }
    
    /**
     * 
     * @param refundPrice
     * @param refundMethod
     * @return
     */
    public Order refund(BigDecimal refundPrice, RefundMethod refundMethod) {
        this.orderStatus = OrderStatus.REFUNDED;
        this.paymentStatus = PaymentStatus.SYSTEMREFUNDED;
        this.refundPrice = refundPrice.multiply(new BigDecimal(100)).intValue() - this.getPayingPrice();
        this.refundMethod = refundMethod;
        return this;
    }
    
    /**
     * 
     * @return
     */
    public Order disable() {
        this.disabled = true;
        return this;
    }
    
    /**
     * 
     * @param salesman
     * @return
     */
    public Order changeSalesman(Principal salesman) {
        this.salesman = salesman;
        return this;
    }
    
    /**
     * 
     * @param deposit
     * @return
     */
    public Order deposit(BigDecimal deposit) {
        this.deposit = deposit.multiply(new BigDecimal("100")).intValue();
        this.paidPrice = paidPrice + this.deposit;
        return this;
    }
    
    /**
     * 
     * @param offer
     * @return
     */
    public Order payOffer(BigDecimal offer) {
        this.offer = offer.multiply(new BigDecimal("100")).intValue();
        this.paidPrice = paidPrice + this.offer;
        this.payOffer = true;
        return this;
    }
    
    /**
     * 
     * @param price
     * @return
     */
    public Order editPaidPrice(BigDecimal price) {
        this.paidPrice = this.paidPrice + price.multiply(new BigDecimal("100")).intValue();
        return this;
    }
    
    /**
     * 
     * @param price
     * @return
     */
    public Order editPaidPrice(int price) {
        this.paidPrice = price;
        return this;
    }
    
    /**
     * 
     * @param balance
     * @return
     */
    public Order payBalance(BigDecimal balance) {
        this.paidPrice = this.paidPrice + balance.multiply(new BigDecimal(100)).intValue();
        return this;
    }
    
    /**
     * 
     * @return
     */
    public String getProductCover() {
        return this.product.getCover();
    }
    
    /**
     * 
     * @return
     */
    public String getProductName() {
        return this.product.getName();
    }
    
    /**
     * 
     * @return
     */
    @Transient
    public int getPayingPrice() {
        return this.price - this.paidPrice;
    }

    @Transient
    public boolean isOnlineYear() {
        boolean isOnlineYear = false;

        if(attrs != null && attrs.size() > 0) {
            OrderAttribute attr = attrs.get("isOnlineYear");
            if(attr != null && "1".equals(attr.getValue())) {
                isOnlineYear = true;
            }
        }

        return isOnlineYear;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }
    
    /**
	 * @return the userSourceType
	 */
	public UserSourceType getUserSourceType() {
		return userSourceType;
	}

    /**
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * @return the orderType
     */
    public OrderType getOrderType() {
        return orderType;
    }

    /**
     * @return the product
     */
    public Product getProduct() {
        return product;
    }

    /**
     * @return the course
     */
    public Course getCourse() {
        return course;
    }

    /**
     * @return the site
     */
    public Site getSite() {
        return site;
    }

    /**
     * @return the user
     */
    public User getUser() {
        return user;
    }

    /**
     * @return the student
     */
    public Student getStudent() {
        return student;
    }

    /**
     * @return the originalPrice
     */
    public int getOriginalPrice() {
        return originalPrice;
    }

    /**
     * @return the price
     */
    public int getPrice() {
        return price;
    }

    /**
     * @return the deposit
     */
    public int getDeposit() {
        return deposit;
    }

    /**
     * @return the offer
     */
    public int getOffer() {
        return offer;
    }

    /**
     * @return the payOffer
     */
    public boolean isPayOffer() {
        return payOffer;
    }

    /**
     * @return the paidPrice
     */
    public int getPaidPrice() {
        return paidPrice;
    }

    /**
     * @return the refundMethod
     */
    public RefundMethod getRefundMethod() {
        return refundMethod;
    }

    /**
     * @return the refundPrice
     */
    public int getRefundPrice() {
        return refundPrice;
    }

    /**
     * @return the amount
     */
    public int getAmount() {
        return amount;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the payTime
     */
    public Date getPayTime() {
        return payTime;
    }

    /**
     * @return the payCode
     */
    public String getPayCode() {
        return payCode;
    }

    /**
     * @return the remarks
     */
    public String getRemarks() {
        return remarks;
    }

    /**
     * @return the distributionChannel
     */
    public DistributionChannel getDistributionChannel() {
        return distributionChannel;
    }

    /**
     * @return the paymentMethod
     */
    public PaymentMethod getPaymentMethod() {
        return paymentMethod;
    }

    /**
     * @return the orderStatus
     */
    public OrderStatus getOrderStatus() {
        return orderStatus;
    }

    /**
     * @return the paymentStatus
     */
    public PaymentStatus getPaymentStatus() {
        return paymentStatus;
    }

    /**
     * @return the attrs
     */
    public Map<String, OrderAttribute> getAttrs() {
        return attrs;
    }

    /**
     * @return the investiged
     */
    public boolean isInvestiged() {
        return investiged;
    }

    /**
     * @return the uploadWxc
     */
    public boolean isUploadWxc() {
        return uploadWxc;
    }

    /**
     * @return the uploadLjz
     */
    public boolean isUploadLjz() {
        return uploadLjz;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @return the discountCode
     */
    public String getDiscountCode() {
        return discountCode;
    }

    /**
     * @return the commission
     */
    public int getCommission() {
        return commission;
    }

    /**
     * @return the agent
     */
    public Agent getAgent() {
        return agent;
    }

    /**
     * @return the salesman
     */
    public Principal getSalesman() {
        return salesman;
    }

    /**
     * @return the exportSale
     */
    public boolean isExportSale() {
        return exportSale;
    }

    /**
     * @return the exportReceipt
     */
    public boolean isExportReceipt() {
        return exportReceipt;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }
    
    /**
	 * @param userSourceType the userSourceType to set
	 */
	public void setUserSourceType(UserSourceType userSourceType) {
		this.userSourceType = userSourceType;
	}

    /**
     * @param code the code to set
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * @param orderType the orderType to set
     */
    public void setOrderType(OrderType orderType) {
        this.orderType = orderType;
    }

    /**
     * @param product the product to set
     */
    public void setProduct(Product product) {
        this.product = product;
    }

    /**
     * @param course the course to set
     */
    public void setCourse(Course course) {
        this.course = course;
    }

    /**
     * @param site the site to set
     */
    public void setSite(Site site) {
        this.site = site;
    }

    /**
     * @param user the user to set
     */
    public void setUser(User user) {
        this.user = user;
    }

    /**
     * @param student the student to set
     */
    public void setStudent(Student student) {
        this.student = student;
    }

    /**
     * @param originalPrice the originalPrice to set
     */
    public void setOriginalPrice(int originalPrice) {
        this.originalPrice = originalPrice;
    }

    /**
     * @param price the price to set
     */
    public void setPrice(int price) {
        this.price = price;
    }

    /**
     * @param deposit the deposit to set
     */
    public void setDeposit(int deposit) {
        this.deposit = deposit;
    }

    /**
     * @param offer the offer to set
     */
    public void setOffer(int offer) {
        this.offer = offer;
    }

    /**
     * @param payOffer the payOffer to set
     */
    public void setPayOffer(boolean payOffer) {
        this.payOffer = payOffer;
    }

    /**
     * @param paidPrice the paidPrice to set
     */
    public void setPaidPrice(int paidPrice) {
        this.paidPrice = paidPrice;
    }

    /**
     * @param refundMethod the refundMethod to set
     */
    public void setRefundMethod(RefundMethod refundMethod) {
        this.refundMethod = refundMethod;
    }

    /**
     * @param refundPrice the refundPrice to set
     */
    public void setRefundPrice(int refundPrice) {
        this.refundPrice = refundPrice;
    }

    /**
     * @param amount the amount to set
     */
    public void setAmount(int amount) {
        this.amount = amount;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param payTime the payTime to set
     */
    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }

    /**
     * @param payCode the payCode to set
     */
    public void setPayCode(String payCode) {
        this.payCode = payCode;
    }

    /**
     * @param remarks the remarks to set
     */
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    /**
     * @param distributionChannel the distributionChannel to set
     */
    public void setDistributionChannel(DistributionChannel distributionChannel) {
        this.distributionChannel = distributionChannel;
    }

    /**
     * @param paymentMethod the paymentMethod to set
     */
    public void setPaymentMethod(PaymentMethod paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    /**
     * @param orderStatus the orderStatus to set
     */
    public void setOrderStatus(OrderStatus orderStatus) {
        this.orderStatus = orderStatus;
    }

    /**
     * @param paymentStatus the paymentStatus to set
     */
    public void setPaymentStatus(PaymentStatus paymentStatus) {
        this.paymentStatus = paymentStatus;
    }

    /**
     * @param attrs the attrs to set
     */
    public void setAttrs(Map<String, OrderAttribute> attrs) {
        this.attrs = attrs;
    }

    /**
     * @param investiged the investiged to set
     */
    public void setInvestiged(boolean investiged) {
        this.investiged = investiged;
    }

    /**
     * @param uploadWxc the uploadWxc to set
     */
    public void setUploadWxc(boolean uploadWxc) {
        this.uploadWxc = uploadWxc;
    }

    /**
     * @param uploadLjz the uploadLjz to set
     */
    public void setUploadLjz(boolean uploadLjz) {
        this.uploadLjz = uploadLjz;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

    /**
     * @param discountCode the discountCode to set
     */
    public void setDiscountCode(String discountCode) {
        this.discountCode = discountCode;
    }

    /**
     * @param commission the commission to set
     */
    public void setCommission(int commission) {
        this.commission = commission;
    }

    /**
     * @param agent the agent to set
     */
    public void setAgent(Agent agent) {
        this.agent = agent;
    }

    /**
     * @param salesman the salesman to set
     */
    public void setSalesman(Principal salesman) {
        this.salesman = salesman;
    }

    /**
     * @param exportSale the exportSale to set
     */
    public void setExportSale(boolean exportSale) {
        this.exportSale = exportSale;
    }

    /**
     * @param exportReceipt the exportReceipt to set
     */
    public void setExportReceipt(boolean exportReceipt) {
        this.exportReceipt = exportReceipt;
    }
    
    /**
	 * @return the courseTags
	 */
	public String getCourseTags() {
		return courseTags;
	}
	
	/**
	 * @param courseTags the courseTags to set
	 */
	public void setCourseTags(String courseTags) {
		this.courseTags = courseTags;
	}

}
